define(function (jsonp) {

    function init(key, params) {
        require([path[key].js], function (page) {
            page.init(params);
        });
    }

    path.list = {
        html: 'text!../../page/list/list.html?_v=20151111A2',
        css: 'css!../../page/list/list.css?_v=20151111A2',
        js: 'page/list/list.js?_v=20151111A2'
    };
    path.detail = {
        html: 'text!../../page/detail/detail.html?_v=20151111A2',
        css: 'css!../../page/detail/detail.css?_v=20151111A2',
        js: 'page/detail/detail.js?_v=20151111A2'
    };
    path.deal = {
        html: 'text!../../page/deal/deal.html?_v=20151111A2',
        css: 'css!../../page/deal/deal.css?_v=20151111A2',
        js: 'page/deal/deal.js?_v=20151111A2'
    };
    path.result = {
        html: 'text!../../page/result/result.html?_v=20151111A2',
        css: 'css!../../page/result/result.css?_v=20151111A2',
        js: 'page/result/result.js?_v=20151111A2'
    };

    routie({
        list: function () {
            console.log(location.href);
            init('list');
        },
        'detail/:pid': function (pid) {
            console.log(location.href);
            init('detail', {id: pid});
        },
        'deal/:pid': function (pid) {
            console.log(location.href);
            init('deal', {id: pid});
        },
        'success*':function(){
            console.log(location.href);
            init('result', {result: 'success'});
        },
        'cancel*':function(){
            console.log(location.href);
            init('result', {result: 'cancel'});
        },
        '*': function () {
            console.log(location.href);
            location.hash = '#list';
        }
    });

    juicer.register('transTextH', function (str) {
        return str.replace(/ /g,'&nbsp;').replace(/</g,'&lt').replace(/>/g,'&gt').replace(/\n/g,'<br/>');
    });

});